1. The Field of the Invention
The present invention relates to a method of optimizing performance of a flash memory, and more particularly relates to a method of controlling a flash memory for selecting a page or a block as a unit to process the steps of retrieving or saving data to the flash memory.
2. Description of Related Art
In the conventional method of reading data from any address in a page, due to the physical characteristics of the conventional flash memory, a page is usually taken as a reading unit. For writing data, the flash memory takes a block as a unit and erases the whole block and then writes data into pages in a order of page by page. Thus if the volume of the data is smaller than a block, then data processing is accordingly limited due to the structure limits.
For writing data into a page of the flash memory completely, the physical characteristics of the flash memory requires a page should be absolutely blank or have no data therein and the volume of the data should be equal to a sector. Therefore, the page should be verified that it is completely blank or has no data therein before writing data into page. The term “blank” here means, the data in every pages of the block are “1”. According to the conventional writing method a block is taken as a unit, and therefore to write data into one page of the block, the flash memory has to find an absolutely blank block, namely, a backup block, and then the data is written into the blank page of the new block. So the data in the old block is completely moved into the new block and then, the old block is erased. The old block after being completely erased serves as a new block.
When the volume of the data is equivalent to a few continuous pages, the flash memory controller finds a new block from the flash memory for writing the data into the page thereof; then to move the data into the page of the new block, and after writing of the data is completed, the old block is erased. Because in a host, for instance, a computer, a card reader, a cellular phone and the like, the file arrangement table (FAT) of the flash memory is often updated, and if the data is usually for small files, the flash memory has to work repeatedly according to the rule of first finding a new block, moving data into the new block and then erasing the old block.
Frequent erasing steps would easily damage the internal structure of the flash memory. It is found that after one million times of erasing steps, the flash memory easily gets damaged. Therefore, by reducing the frequency of erasing steps, the service life of the flash memory can be extended. Accordingly, for writing data, if a block is taken as a unit, the erasing frequency cannot be reduced and therefore the service life of the flash memory is limited.